<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AttachmentService
 *
 * @author Administrator
 */

namespace frontend\api\service;

use Qiniu\Auth;
use Yii;

class AttachmentService {

    //put your code here

    /*
     * @return string $upToken
     */
    public function getUploadToken() {
        $bucket =  Yii::$app->param['bucket'];
        $accessKey =  Yii::$app->param['access_key'];//Config::ACCESS_KEY;
        $secretKey = Yii::$app->param['secret_key'];;
        $auth = new Auth($accessKey, $secretKey);
        $policy = array(
            'callbackUrl' => 'http://172.30.251.210/callback.php',
            'callbackBody' => '{"fname":"$(fname)", "fkey":"$(key)", "desc":"$(x:desc)", "uid":' . $uid . '}'
        );

        return $upToken = $auth->uploadToken($bucket, null, 3600, $policy);
    }
    
    public function callback(){
        
    }

}
